﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.XHRS
{
    class Class3
    {
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Period > 0)
            {
                double f = (double)ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("分红率(预估)");

                ppa.Amount += ppa.PolicyActing.PeriodActings[ppa.Period - 1].Amount * f;
            }


            if (ppa.Age < 60)
            {
                if ((ppa.Period + 1) % 2 == 2)
                {
                    da.Value = ppa.Amount * 0.08;
                }
            }
            else
            {
                da.Value = ppa.Amount * 0.16;
            }

        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Age == 66)
            {
                da.Value = ppa.Amount;
            }

        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("疾病身故"))
            {
                if (ppa.Period == 0)
                {
                    da.Value = ppa.Amount * 0.1 + ppa.TotalFee;
                }
                else if (ppa.Age < 66)
                {
                    da.Value = ppa.Amount * 2;
                }
                else if (ppa.Age >= 66)
                {
                    da.Value = ppa.Amount ;
                }

                ppa.SchemePeriodActing.InsurantStates.Add("身故");
                ppa.IsCurrentFinish = true;
            }
            else if (ppa.SchemePeriodActing.InsurantStates.Contains("疾病身故"))
            {

                if (ppa.Age < 66)
                {
                    da.Value = ppa.Amount * 2;
                }
                else if (ppa.Age >= 66)
                {
                    da.Value = ppa.Amount ;
                }

                ppa.SchemePeriodActing.InsurantStates.Add("身故");
                ppa.IsCurrentFinish = true;
            }


        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("疾病身故"))
            {
                if (ppa.Period == 0)
                {
                    da.Value = ppa.Amount * 0.1 + ppa.TotalFee;
                }
                else 
                {
                    da.Value = ppa.Amount * 2;
                }


                ppa.SchemePeriodActing.InsurantStates.Add("身故");
                ppa.IsCurrentFinish = true;
            }
            else if (ppa.SchemePeriodActing.InsurantStates.Contains("意外身故"))
            {

                da.Value = ppa.Amount * 2;

                ppa.SchemePeriodActing.InsurantStates.Add("身故");
                ppa.IsCurrentFinish = true;
            }
            else if (ppa.SchemePeriodActing.InsurantStates.Contains("全残"))
            {
                if (ppa.Period == 0)
                {
                    da.Value = ppa.Amount * 0.1 + ppa.TotalFee;
                }
                else
                {
                    da.Value = ppa.Amount * 2;
                }
                ppa.IsCurrentFinish = true;
            }


        }
    }
}
